<template>
  <div>
      <myheader/>
      选择分类<br>
      <replay :data='catelist'/>
         <van-field
            v-model="form.name"
            name="name"
            label="名称"
            placeholder="名称"
            :rules="[{ required: true, message: '请填写名称' }]"
          />
           <van-field
            v-model="form.leval"
            name="leval"
            label="等级"
            placeholder="等级"
            :rules="[{ required: true, message: '请填写等级' }]"
          />
           <van-field
            v-model="form.params"
            name="params"
            label="参数配置"
            placeholder="参数配置"
          />
          <van-button round block type="info" style="width:200px" @click="add">提交</van-button>
  </div>
</template>
<script> 
import myheader from '@/components/myheader'
import reply from '@/components/reply'
export default {
  components: { myheader },
    data(){
        return{
            form:{parent:0}
        }
    },
    methods:{
        add(){
          // 获取父id如果有更新
          let pid = localStorage.getItem('pid')
          if(pid){
            this.form.parent = pid
          }
            this.$axios.post('cpurse/cateM',this.form)
            .then(res=>{
                
            })
        },
        // 获取所有分类
        getCatelist(){
          this$axiosget('course/cate')
          .then(res=>{
            this.catelist={'id':0,'name':'','son':res.data.list}
          }) 
        },
    },
    mounted(){
      this.getCatelist()
    },
    components:{
        'myheader':myheader,
        'reply': reply
    }
}
</script>

<style>

</style>